home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / RCS / netInet.h,v < prev    next >
Encoding:
Text File  |  1992-08-05  |  20.9 KB  |  804 lines

  1. head     1.7;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.6.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.7
  10. date     92.08.05.16.34.23;  author jhh;  state Exp;
  11. branches ;
  12. next     1.6;
  13.  
  14. 1.6
  15. date     89.06.23.11.30.13;  author rab;  state Exp;
  16. branches 1.6.1.1;
  17. next     1.5;
  18.  
  19. 1.5
  20. date     89.06.03.14.01.08;  author mendel;  state Exp;
  21. branches ;
  22. next     1.4;
  23.  
  24. 1.4
  25. date     88.10.04.16.35.52;  author mendel;  state Exp;
  26. branches ;
  27. next     1.3;
  28.  
  29. 1.3
  30. date     88.07.25.21.00.54;  author mendel;  state Exp;
  31. branches ;
  32. next     1.2;
  33.  
  34. 1.2
  35. date     88.06.21.13.09.39;  author ouster;  state Exp;
  36. branches ;
  37. next     1.1;
  38.  
  39. 1.1
  40. date     88.06.21.13.04.45;  author ouster;  state Exp;
  41. branches ;
  42. next     ;
  43.  
  44. 1.6.1.1
  45. date     91.10.21.22.15.37;  author kupfer;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49.  
  50. desc
  51. @@
  52.  
  53.  
  54. 1.7
  55. log
  56. @added inet address compare and copy routines
  57. @
  58. text
  59. @/*
  60.  * netInet.h --
  61.  *
  62.  *    Declarations of data structures and constants for the DARPA Internet 
  63.  *    protocol suite.
  64.  *
  65.  * Copyright 1987, 1988 Regents of the University of California
  66.  * Permission to use, copy, modify, and distribute this
  67.  * software and its documentation for any purpose and without
  68.  * fee is hereby granted, provided that the above copyright
  69.  * notice appear in all copies.  The University of California
  70.  * makes no representations about the suitability of this
  71.  * software for any purpose.  It is provided "as is" without
  72.  * express or implied warranty.
  73.  *
  74.  * $Header: /sprite/src/lib/include/RCS/netInet.h,v 1.6 89/06/23 11:30:13 rab Exp Locker: jhh $ SPRITE (Berkeley)
  75.  */
  76.  
  77. #ifndef _NETINET
  78. #define _NETINET
  79.  
  80. #include "machparam.h"
  81. #include "netEther.h"
  82.  
  83.  
  84. /*
  85.  * Definition of the 32-bit Internet Address.
  86.  */
  87.  
  88. typedef unsigned int Net_InetAddress;
  89.  
  90. /*
  91.  * Net_InetAddrCmp --
  92.  *
  93.  * Compare two internet addresses. Returns 0 if they are the same, 1 otherwise.
  94.  */
  95. #define Net_InetAddrCmp(a,b) ((a) != (b))
  96.  
  97. #define Net_InetAddrCopy(src, dest) ((dest) = (src))
  98.  
  99. /*
  100.  * Structure of the Ethernet Address Resolution Protocol and Reverse ARP 
  101.  * packets, according to RFC826 (ARP) and RFC903 (RARP).
  102.  */
  103. typedef struct { 
  104.     unsigned short    hardwareType;        /* "Hardware address space (e.g.
  105.                          * Ethernet, Packet Radio Net.)"
  106.                          */
  107.     unsigned short    protocolType;        /* "Protocol Address Space"
  108.                          * specifies format of protocol
  109.                          * addresses. Value is one
  110.                          * of the defined packet types 
  111.                          * in netEther.h. */
  112.     unsigned char    hardwareAddrLen;    /* length in bytes of hardware
  113.                          * addresses. */
  114.     unsigned char    protocolAddrLen;    /* length in bytes of protocol
  115.                          * addresses. */
  116.     unsigned short    opcode;            /* see below. */
  117. }  Net_ArpHeader;
  118.  
  119. typedef struct {
  120.     Net_EtherHdr    header;            /* packet header */
  121.     unsigned short    hardwareType;        /* "Hardware address space (e.g.
  122.                          * Ethernet, Packet Radio Net.)"
  123.                          */
  124.     unsigned short    protocolType;        /* "Protocol Address Space"
  125.                          * specifies format of protocol
  126.                          * addresses. Value is one
  127.                          * of the defined packet types 
  128.                          * in netEther.h. */
  129.     unsigned char    hardwareAddrLen;    /* length in bytes of hardware
  130.                          * addresses. */
  131.     unsigned char    protocolAddrLen;    /* length in bytes of protocol
  132.                          * addresses. */
  133.     unsigned short    opcode;            /* see below. */
  134.     Net_EtherAddress    senderEtherAddr;    /* hardware address of sender
  135.                          * of the packet. */
  136.     Net_InetAddress    senderProtAddr;        /* protocol address of sender
  137.                          * of the packet. */
  138.     Net_EtherAddress    targetEtherAddr;    /* hardware address of target
  139.                          * (if known). */
  140.     Net_InetAddress    targetProtAddr;        /* protocol address of target.*/
  141. } Net_ArpPacket;
  142.  
  143. /*
  144.  * Value for the hardwareType field in Net_ArpPacket.
  145.  *   NET_ARP_TYPE_ETHER         using ethernet hardware.
  146.  */
  147.  
  148. #define NET_ARP_TYPE_ETHER    1
  149.  
  150. /*
  151.  * Values for the opcode field in Net_ArpPacket:
  152.  *   NET_ARP_REQUEST        request ethernet address for a given IP address.
  153.  *   NET_ARP_REPLY        answer for above request.
  154.  *   NET_RARP_REQUEST        request IP address for a given ethernet address.
  155.  *   NET_RARP_REPLY        answer for above request.
  156.  */
  157.  
  158. #define NET_ARP_REQUEST        1
  159. #define NET_ARP_REPLY        2
  160. #define NET_RARP_REQUEST    3
  161. #define NET_RARP_REPLY        4
  162.  
  163.  
  164.  
  165. #define NET_INET_BROADCAST_ADDR        ((Net_InetAddress) 0xFFFFFFFF)
  166. #define NET_INET_ANY_ADDR        ((Net_InetAddress) 0)
  167.  
  168. #define NET_INET_CLASS_A_ADDR(addr) \
  169.             (((unsigned int)(addr) & 0x80000000) == 0)
  170. #define NET_INET_CLASS_A_HOST_MASK        0x00FFFFFF
  171. #define NET_INET_CLASS_A_NET_MASK        0xFF000000
  172. #define NET_INET_CLASS_A_SHIFT            24
  173.  
  174. #define NET_INET_CLASS_B_ADDR(addr) \
  175.             (((unsigned int)(addr) & 0xC0000000) == 0x80000000)
  176. #define NET_INET_CLASS_B_HOST_MASK        0x0000FFFF
  177. #define NET_INET_CLASS_B_NET_MASK        0xFFFF0000
  178. #define NET_INET_CLASS_B_SHIFT            16
  179.  
  180. #define NET_INET_CLASS_C_ADDR(addr) \
  181.             (((unsigned int)(addr) & 0xE0000000) == 0xC0000000)
  182. #define NET_INET_CLASS_C_HOST_MASK        0x000000FF
  183. #define NET_INET_CLASS_C_NET_MASK        0xFFFFFF00
  184. #define NET_INET_CLASS_C_SHIFT            8
  185.  
  186. /*
  187.  * Class D: multicast addressing (see RFC988, RFC966).
  188.  */
  189. #define NET_INET_CLASS_D_ADDR(addr) \
  190.             (((unsigned int)(addr) & 0xF0000000) == 0xE0000000)
  191. #define NET_INET_CLASS_D_NET_MASK        0x0FFFFFFF
  192.  
  193. /*
  194.  * Class E: reserved.
  195.  */
  196. #define NET_INET_CLASS_E_ADDR(addr) \
  197.             (((unsigned int)(addr) & 0xF0000000) == 0xF0000000)
  198.  
  199. /*
  200.  * Synonym address for the local host.
  201.  */
  202. #define NET_INET_LOCAL_HOST        0x7F000001
  203.  
  204.  
  205.  
  206. /*
  207.  * Structure of an Internet packet header, according to RFC791.
  208.  */
  209.  
  210. typedef struct {
  211. #if  BYTE_ORDER == LITTLE_ENDIAN
  212.     unsigned int    headerLen:4,    /* Length of header in 32-bit words. */
  213.             version:4;    /* Version. Defined below. */
  214. #else
  215.     unsigned int    version:4,
  216.             headerLen:4;
  217. #endif
  218.     unsigned char    typeOfService;    /* See below. */
  219.     unsigned short    totalLen;    /* Length in bytes of the 
  220.                      * datagram including header and data.*/
  221.     unsigned short    ident;        /* Used for fragmentation reassembly. */
  222. #if BYTE_ORDER == LITTLE_ENDIAN
  223.     unsigned int    fragOffset:13,    /* Offset from beginning of unfragmented
  224.                      * packet. */
  225.             flags:3;    /* Fragment flags. See below. */
  226. #else
  227.     unsigned int    flags:3,
  228.             fragOffset:13;
  229. #endif
  230.     unsigned char    timeToLive;    /* Max. time the packet is allowed to
  231.                      * be in the internet system. When TTL
  232.                      * goes to 0, the packet is destroyed.*/
  233.     unsigned char    protocol;    /* Protocol used in the data portion.
  234.                      * Defined below. */
  235.     unsigned short    checksum;    /* Checksum of the header. */
  236.     Net_InetAddress    source;        /* Source of the packet. */
  237.     Net_InetAddress    dest;        /* Destination of the packet. */
  238.     /*
  239.      * Options may follow at this point, before the data.
  240.      */
  241. } Net_IPHeader;
  242.  
  243. /*
  244.  * IP Pseudo Header is used by UDP and TCP checksums to make sure
  245.  * the packet is not mis-routed.
  246.  */
  247. typedef struct {
  248.     Net_InetAddress    source;        /* Source of the packet. */
  249.     Net_InetAddress    dest;        /* Destination of the packet. */
  250.     unsigned char    zero;        /* must be zero. */
  251.     unsigned char    protocol;    /* Protocol # (UDP, TCP). */
  252.     unsigned short    len;        /* # of bytes in header and data. */
  253. } Net_IPPseudoHdr;
  254.  
  255. #define NET_IP_VERSION        4
  256. #define NET_IP_MAX_HDR_SIZE    60
  257.  
  258. /*
  259.  * IP implementation parameters:
  260.  *  NET_IP_MAX_TTL        - Max. value for timeToLive field (in seconds).
  261.  *  NET_IP_MAX_FRAG_TTL        - Max. time-to-live for fragments.
  262.  *  NET_IP_TTL_DECR        - The value ttl is decremented by when a 
  263.  *                   packet is forwarded.
  264.  *  NET_IP_MAX_SEG_SIZE        - Max. segment size.
  265.  *  NET_IP_MAX_PACKET_SIZE    - Largest packet size.
  266.  */
  267.  
  268. #define NET_IP_MAX_TTL            255
  269. #define NET_IP_MAX_FRAG_TTL        15
  270. #define NET_IP_TTL_DECR            1
  271. #define NET_IP_MAX_SEG_SIZE        576
  272. #define NET_IP_MAX_PACKET_SIZE        65535
  273.  
  274. /*
  275.  * Definitions of the typeOfService flags in the Internet header.
  276.  * According to p. 12 of RFC791, the type of service field has the
  277.  * the following subfields:
  278.  *    precedence:    bits 0-2    (most sig. bits)
  279.  *     delay        bit  3
  280.  *     thruput        bit  4
  281.  *     reliability    bit  5
  282.  *     reserved    bit  6-7    (least sig. bits)
  283.  * The value must be composed of the OR of one flag from each of the following
  284.  * groups:
  285.  */
  286.  
  287. #define NET_IP_SERV_PREC_NET_CTL    0xE0
  288. #define NET_IP_SERV_PREC_INET_CTL    0xC0
  289. #define NET_IP_SERV_PREC_CRITIC        0xA0
  290. #define NET_IP_SERV_PREC_FLASH_OVR    0x80
  291. #define NET_IP_SERV_PREC_FLASH        0x60
  292. #define NET_IP_SERV_PREC_IMMED        0x40
  293. #define NET_IP_SERV_PREC_PRIORITY    0x20
  294. #define NET_IP_SERV_PREC_ROUTINE    0x00
  295.  
  296. #define NET_IP_SERV_NORM_DELAY        0x00
  297. #define NET_IP_SERV_LOW_DELAY        0x10
  298.  
  299. #define NET_IP_SERV_NORM_THRUPUT    0x00
  300. #define NET_IP_SERV_HIGH_THRUPUT    0x08
  301.  
  302. #define NET_IP_SERV_NORM_RELIABL    0x00
  303. #define NET_IP_SERV_HIGH_RELIABL    0x04
  304.  
  305. /*
  306.  * Values for the flags field in the IP header.
  307.  *    NET_IP_LAST_FRAG    last fragment of the bunch. implies the
  308.  *                packet can be fragmented if necessary.
  309.  *    NET_IP_MORE_FRAGS    expect more fragments.
  310.  *    NET_IP_DONT_FRAG    the can't be fragmented so discard if can't
  311.  *                transmit.
  312.  *
  313.  * The high-order bit of the field must be 0.
  314.  */
  315.  
  316. #define NET_IP_LAST_FRAG        0x0
  317. #define NET_IP_MORE_FRAGS        0x1
  318. #define NET_IP_DONT_FRAG        0x2
  319.  
  320.  
  321. /*
  322.  * Values for the protocol field in the IP packet header from RFC990.
  323.  * The RFC does not assign a number for IP, so we use 0 (even though
  324.  * it is reserved).
  325.  */
  326.  
  327. #define NET_IP_PROTOCOL_IP        0
  328. #define NET_IP_PROTOCOL_ICMP        1
  329. #define NET_IP_PROTOCOL_TCP        6
  330. #define NET_IP_PROTOCOL_EGP        8
  331. #define NET_IP_PROTOCOL_UDP        17
  332. #define NET_IP_PROTOCOL_SPRITE        90
  333.  
  334.  
  335. /*
  336.  * Definitions of IP options.
  337.  * There are two formats for the options:
  338.  *   1) single octet of option-type.
  339.  *   2) an option-type octet, an option length, and the actual data octets.
  340.  *
  341.  * The option type is composed of 3 fields: copied flag (1 bit), 
  342.  * option class (2 bits), and an option number (5 bits).
  343.  */
  344.  
  345. /*
  346.  * Definitions of offsets within an option for the type, length and next-
  347.  * option-offset octets. The minimum value for the next-option offset 
  348.  * ("pointer") is 4.  The pointer is used in the 3 routing options and 
  349.  * the timestamp option.
  350.  */
  351. #define NET_IP_OPT_TYPE_OFFSET        0
  352. #define NET_IP_OPT_LEN_OFFSET        1
  353. #define NET_IP_OPT_PTR_OFFSET        2
  354. #define NET_IP_OPT_MIN_PTR        4
  355.  
  356. #define NET_IP_OPT_MAX_LEN        40
  357.  
  358. /*
  359.  * Macros to access the option-type fields.
  360.  *  NET_IP_OPT_COPIED    - 0 means not copied, 1 means copied.
  361.  *  NET_IP_OPT_CLASS    - see below.
  362.  *  NET_IP_OPT_NUMBER    - see below.
  363.  */
  364.  
  365. #define NET_IP_OPT_COPIED(opt)        ((opt) & 0x80)
  366. #define NET_IP_OPT_CLASS(opt)        ((opt) & 0x60)
  367. #define NET_IP_OPT_NUMBER(opt)        ((opt) & 0x1f)
  368.  
  369. /*
  370.  * Values for NET_IP_OPT_CLASS as masks.
  371.  */
  372. #define NET_IP_OPT_CLASS_CONTROL        0x00
  373. #define NET_IP_OPT_CLASS_RESERVED1        0x20
  374. #define NET_IP_OPT_CLASS_DEBUG            0x40
  375. #define NET_IP_OPT_CLASS_RESERVED2        0x60
  376.  
  377. /*
  378.  * Complete values for the option types, including the copied and class fields
  379.  * as well as the number field.   The definitions are listed in the same 
  380.  * order as described in RFC791, p. 16ff.
  381.  */
  382.  
  383. #define NET_IP_OPT_END_OF_LIST        0x00
  384. #define NET_IP_OPT_NOP            0x01
  385. #define NET_IP_OPT_SECURITY        0x82
  386. #define NET_IP_OPT_LOOSE_ROUTE        0x83
  387. #define NET_IP_OPT_STRICT_ROUTE        0x89
  388. #define NET_IP_OPT_REC_ROUTE        0x07
  389. #define NET_IP_OPT_STREAM_ID        0x88
  390. #define NET_IP_OPT_TIMESTAMP        0x44
  391.  
  392. /*
  393.  * Foramt of the timestamp option header.
  394.  */
  395. typedef struct {
  396.     unsigned char    type;
  397.     unsigned char    len;            /* Total len of option. */
  398.     unsigned char    pointer;        /* Offset into option where
  399.                          * to add t.s. */
  400. #if  BYTE_ORDER == LITTLE_ENDIAN
  401.     unsigned int    flags:4,        /* Defined below. */
  402.             overflow:4;        /* # of hosts who weren't
  403.                          * able to add a t.s. */
  404. #else
  405.     unsigned int    overflow:4,
  406.             flags:4;
  407. #endif
  408. } Net_IPTimestampHdr;
  409.  
  410. /*
  411.  *  Values of the flags field in Net_IPTimestampHdr.
  412.  */
  413. #define NET_IP_OPT_TS_ONLY        0
  414. #define NET_IP_OPT_TS_AND_ADDR        1
  415. #define NET_IP_OPT_TS_ADDR_SPEC        3
  416.  
  417. /*
  418.  * Interet time value is a "right-justified, 32-bit" time in milliseconds
  419.  * since midnight Universal Time (UT).
  420.  */
  421. typedef int Net_InetTime;
  422.  
  423.  
  424. /*
  425.  * Structure of an TCP packet header, according to RFC793.
  426.  */
  427.  
  428. typedef struct {
  429.     unsigned short    srcPort;    /* Source port # */
  430.     unsigned short    destPort;    /* Destination port # */
  431.     unsigned int    seqNum;        /* Seq. # of 1st byte in the segment */
  432.     unsigned int    ackNum;        /* Next seq. # we expect */
  433. #if BYTE_ORDER == LITTLE_ENDIAN
  434.     unsigned int    reserved1:4,    /* Must be zero. */
  435.             dataOffset:4,    /* # of 32-bit words in this header */
  436.             flags:6,    /* Control flags, define below. */
  437.             reserved2:2;    /* Must be zero */
  438. #else
  439.     unsigned int    dataOffset:4,
  440.             reserved:6,
  441.             flags:6;
  442. #endif
  443.     unsigned short    window;        /* # of bytes we are willing to accept*/
  444.     unsigned short    checksum;    /* Checksum of IP pseudo-header, 
  445.                      * TCP header and data. */
  446.     unsigned short    urgentOffset;    /* Start of urgent data as an offset
  447.                      * from the seq. # of this segment. */
  448. } Net_TCPHeader;
  449.  
  450. #define NET_TCP_MAX_HDR_SIZE    60
  451. #define NET_TCP_TTL        30
  452.  
  453. /*
  454.  * TCP header control flags: (p. 16, rfc793)
  455.  *
  456.  *    URG -  Urgent Pointer field significant
  457.  *    ACK -  Acknowledgment field significant
  458.  *    PSH -  Push Function
  459.  *    RST -  Reset the connection
  460.  *    SYN -  Synchronize sequence numbers
  461.  *    FIN -  No more data from sender
  462.  */
  463.  
  464. #define NET_TCP_FIN_FLAG    0x01
  465. #define NET_TCP_SYN_FLAG    0x02
  466. #define NET_TCP_RST_FLAG    0x04
  467. #define NET_TCP_PSH_FLAG    0x08
  468. #define NET_TCP_ACK_FLAG    0x10
  469. #define NET_TCP_URG_FLAG    0x20
  470.  
  471.  
  472. /*
  473.  * TCP options flags:        (p. 16, rfc793)
  474.  *    EOL        - End of option list
  475.  *    NOP        - No-operation
  476.  *    MAX_SEG_SIZE    - Maximum segment size
  477.  */
  478.  
  479. #define NET_TCP_OPTION_EOL        0x0
  480. #define NET_TCP_OPTION_NOP        0x1
  481. #define NET_TCP_OPTION_MAX_SEG_SIZE    0x2
  482.  
  483. #define NET_TCP_MAX_SEG_SIZE        512
  484.  
  485.  
  486.  
  487. /*
  488.  * Structure of an UDP packet header, according to RFC768.
  489.  */
  490.  
  491. typedef struct {
  492.     unsigned short    srcPort;    /* Source port. */
  493.     unsigned short    destPort;    /* Destination port. */
  494.     unsigned short    len;        /* # of bytes in header and data. */
  495.     unsigned short    checksum;    /* Checksum of IP pseudo-header,
  496.                      * UDP header and data. */
  497. } Net_UDPHeader;
  498.  
  499. #define NET_UDP_TTL            30
  500.  
  501.  
  502. /*
  503.  * Structure of various ICMP packets, according to RFC792.
  504.  * The data structures for ICMP data is broken into 2 parts: 
  505.  * a 4-byte header that is common to all ICMP packet types and
  506.  * a type-dependent data part.
  507.  *
  508.  * The packets that include the IP header + the first 64 bits of data
  509.  * consist of the basic header, plus room for the header options followed
  510.  * by space for the data. Enough space to hold the maximum amount of
  511.  * header options is reserved; if the size of the options is smaller than
  512.  * maximum, the 64 bits of data will be placed immediately after the end
  513.  * of the options. Therefore the "char data[8]" field is there to reserve
  514.  * space in case of a maximum-sized header is present.
  515.  */
  516.  
  517. typedef struct {
  518.     unsigned char    type;        /* Type of message, define below. */
  519.     unsigned char    code;        /* Type sub code, define below. */
  520.     unsigned short    checksum;    /* Checksum of ICMP message. */
  521. } Net_ICMPHeader;
  522.  
  523. /*
  524.  * Data for "Destination unreachable", "Time exceeded", 
  525.  *  "Source Quench" messages.
  526.  */
  527. typedef struct {
  528.     int            unused;    
  529.     Net_IPHeader    ipHeader;
  530.     char        hdrOptions[NET_IP_MAX_HDR_SIZE - sizeof(Net_IPHeader)];
  531.     char        data[8];
  532. } Net_ICMPDataMisc;
  533.  
  534. /*
  535.  * Data for "Redirect" message.
  536.  */
  537. typedef struct {
  538.     Net_InetAddress    gatewayAddr;
  539.     Net_IPHeader    ipHeader;
  540.     char        hdrOptions[NET_IP_MAX_HDR_SIZE - sizeof(Net_IPHeader)];
  541.     char        data[8];
  542. } Net_ICMPDataRedir;
  543.  
  544. /*
  545.  * Data for "Parameter Problem" message.
  546.  */
  547. typedef struct {
  548.     unsigned char    paramOffset;
  549.     char        unused1;
  550.     short        unused2;
  551.     Net_IPHeader    ipHeader;
  552.     char        hdrOptions[NET_IP_MAX_HDR_SIZE - sizeof(Net_IPHeader)];
  553.     char        data[8];
  554. } Net_ICMPDataParam;
  555.  
  556. /*
  557.  * Data for "Information Request", "Information Reply", "Echo" and "Echo Reply"
  558.  * messages. The echo messages also have additional data following.
  559.  */
  560. typedef struct {
  561.     unsigned short    id;
  562.     unsigned short    seqNum;
  563. } Net_ICMPDataInfoEcho;
  564.  
  565.  
  566. /*
  567.  * Data for "Address Mask Request" and "Address Mask Reply" messages.
  568.  */
  569. typedef struct {
  570.     unsigned short    id;
  571.     unsigned short    seqNum;
  572.     unsigned int    addrMask;
  573. } Net_ICMPDataMask;
  574.  
  575. /*
  576.  * Data for "Timestamp" and "Timestamp Reply" message.
  577.  */
  578. typedef struct {
  579.     unsigned short    id;
  580.     unsigned short    seqNum;
  581.     unsigned int    origTime;
  582.     unsigned int    recvTime;
  583.     unsigned int    transmitTime;
  584. } Net_ICMPDataTime;
  585.  
  586.  
  587. /*
  588.  * A complete definition of an ICMP packet.
  589.  */
  590.  
  591. typedef struct {
  592.     Net_ICMPHeader    header;
  593.     union {
  594.     Net_ICMPDataMisc    overlay;    /* used to format packets that
  595.                          * return the IP header & data*/
  596.     Net_ICMPDataMisc    unreach;    /* NET_ICMP_UNREACHABLE */
  597.     Net_ICMPDataMisc    timeExceed;    /* NET_ICMP_TIME_EXCEED */
  598.     Net_ICMPDataMisc    quench;        /* NET_ICMP_SOURCE_QUENCH */
  599.     Net_ICMPDataParam    param;        /* NET_ICMP_PARAM_PROB */
  600.     Net_ICMPDataRedir    redirect;    /* NET_ICMP_REDIRECT */
  601.     Net_ICMPDataTime    timeStamp;    /* NET_ICMP_TIMESTAMP, _REPLY */
  602.     Net_ICMPDataMask    mask;        /* NET_ICMP_MASK_REQ, _REPLY */
  603.     Net_ICMPDataInfoEcho    info;        /* NET_ICMP_INFO_REQ , _REPLY */
  604.     Net_ICMPDataInfoEcho    echo;        /* NET_ICMP_ECHO, _REPLY */
  605.     } data;
  606. } Net_ICMPPacket;
  607.  
  608. #define NET_ICMP_MIN_LEN    8
  609.  
  610. /*
  611.  * Definition of type and code field values.
  612.  */
  613.  
  614. #define    NET_ICMP_ECHO_REPLY        0    /* Echo reply */
  615.  
  616. #define    NET_ICMP_UNREACHABLE        3    /* Dest unreachable, codes: */
  617. #define     NET_ICMP_UNREACH_NET           0    /*  - Bad net */
  618. #define     NET_ICMP_UNREACH_HOST           1    /*  - Bad host */
  619. #define     NET_ICMP_UNREACH_PROTOCOL       2    /*  - Bad protocol */
  620. #define     NET_ICMP_UNREACH_PORT           3    /*  - Bad port */
  621. #define     NET_ICMP_UNREACH_NEED_FRAG       4    /*  - IP_DF caused drop */
  622. #define     NET_ICMP_UNREACH_SRC_ROUTE       5    /*  - Source route failed */
  623.  
  624. #define    NET_ICMP_SOURCE_QUENCH        4    /* Source quench */
  625. #define    NET_ICMP_REDIRECT        5    /* Shorter route, codes: */
  626. #define     NET_ICMP_REDIRECT_NET           0    /*  - For network */
  627. #define     NET_ICMP_REDIRECT_HOST           1    /*  - For host */
  628. #define     NET_ICMP_REDIRECT_TOS_NET       2    /*  - For type of service and 
  629.                          *    net. */
  630. #define     NET_ICMP_REDIRECT_TOS_HOST       3    /*  - For type of service and 
  631.                          *     host. */
  632. #define    NET_ICMP_ECHO            8    /* Echo service */
  633. #define    NET_ICMP_TIME_EXCEED        11    /* Time exceeded, code: */
  634. #define     NET_ICMP_TIME_EXCEED_TTL       0    /*  - ttl==0 in transit */
  635. #define     NET_ICMP_TIME_EXCEED_REASS       1    /*  - ttl==0 in reassembly */
  636. #define    NET_ICMP_PARAM_PROB        12    /* IP header bad */
  637. #define    NET_ICMP_TIMESTAMP        13    /* Timestamp request */
  638. #define    NET_ICMP_TIMESTAMP_REPLY    14    /* Timestamp reply */
  639. #define    NET_ICMP_INFO_REQ        15    /* Information request */
  640. #define    NET_ICMP_INFO_REPLY        16    /* Information reply */
  641. #define    NET_ICMP_MASK_REQ        17    /* Address mask request */
  642. #define    NET_ICMP_MASK_REPLY        18    /* Address mask reply */
  643.  
  644. #define    NET_ICMP_MAX_TYPE        18
  645.  
  646.  
  647. /*
  648.  * Definition of a socket address. To be compatible with the Unix sockaddr_in
  649.  * structure, there are address family and padding fields. They aren't used
  650.  * by the Sprite Internet server.
  651.  */
  652. typedef struct {
  653.     short        addrFamily;    /* For Unix compatibilty, == AF_INET */
  654.     unsigned short    port;
  655.     Net_InetAddress    address;
  656.     char        padding[8];    /* Not used. */
  657. } Net_InetSocketAddr;
  658.  
  659. #endif /* _NETINET */
  660. @
  661.  
  662.  
  663. 1.6
  664. log
  665. @*** empty log message ***
  666. @
  667. text
  668. @d16 1
  669. a16 1
  670.  * $Header: /sprite/src/lib/include/RCS/netInet.h,v 1.5 89/06/03 14:01:08 mendel Exp Locker: rab $ SPRITE (Berkeley)
  671. d32 8
  672. @
  673.  
  674.  
  675. 1.6.1.1
  676. log
  677. @Initial branch for Sprite server.
  678. @
  679. text
  680. @d16 1
  681. a16 1
  682.  * $Header: /sprite/src/lib/include/RCS/netInet.h,v 1.6 89/06/23 11:30:13 rab Exp $ SPRITE (Berkeley)
  683. @
  684.  
  685.  
  686. 1.5
  687. log
  688. @1) Added Net_ArpHeader header declarations.
  689. 2) Added NET_IP_PROTOCOL_SPRITE declaration.
  690. @
  691. text
  692. @d16 1
  693. a16 1
  694.  * $Header: /sprite/src/lib/include/RCS/netInet.h,v 1.4 88/10/04 16:35:52 mendel Exp Locker: mendel $ SPRITE (Berkeley)
  695. d146 1
  696. a146 1
  697.     unsigned char    headerLen:4,    /* Length of header in 32-bit words. */
  698. d149 1
  699. a149 1
  700.     unsigned char    version:4,
  701. d157 1
  702. a157 1
  703.     unsigned short    fragOffset:13,    /* Offset from beginning of unfragmented
  704. d161 1
  705. a161 1
  706.     unsigned short    flags:3,
  707. d335 1
  708. a335 1
  709.     unsigned char    flags:4,        /* Defined below. */
  710. d339 1
  711. a339 1
  712.     unsigned char    overflow:4,
  713. d368 1
  714. a368 1
  715.     unsigned short    reserved1:4,    /* Must be zero. */
  716. d371 1
  717. a371 1
  718.                 reserved2:2;    /* Must be zero */
  719. d373 1
  720. a373 1
  721.     unsigned short    dataOffset:4,
  722. d375 1
  723. a375 1
  724.                 flags:6;
  725. d593 1
  726. a593 1
  727. #endif _NETINET
  728. @
  729.  
  730.  
  731. 1.4
  732. log
  733. @Patched tcp header declaration for little endian hosts.
  734. @
  735. text
  736. @d16 1
  737. a16 1
  738.  * $Header: netInet.h,v 1.3 88/07/25 21:00:54 mendel Exp $ SPRITE (Berkeley)
  739. d37 16
  740. d56 1
  741. a56 1
  742.                           * Ethernet, Packet Radio Net.)"
  743. d153 1
  744. a153 1
  745.     unsigned short    totalLen;    /* Length in 32-bit words of the 
  746. d266 1
  747. @
  748.  
  749.  
  750. 1.3
  751. log
  752. @Modified to use BYTE_ORDER == LITTLE_ENDIAN #if's.
  753. @
  754. text
  755. @d16 1
  756. a16 1
  757.  * $Header: netInet.h,v 1.2 88/06/21 13:09:39 ouster Exp $ SPRITE (Berkeley)
  758. d351 4
  759. a354 3
  760.     unsigned short    flags:6,    /* Control flags, define below. */
  761.                 reserved:6,    /* Must be zero */
  762.             dataOffset:4;    /* # of 32-bit words in this header */
  763. @
  764.  
  765.  
  766. 1.2
  767. log
  768. @*** empty log message ***
  769. @
  770. text
  771. @d16 1
  772. a16 1
  773.  * $Header: netInet.h,v 1.1 88/06/21 13:04:45 ouster Exp $ SPRITE (Berkeley)
  774. d22 1
  775. d129 1
  776. a129 1
  777. #ifdef LITTLE_ENDIAN
  778. d140 1
  779. a140 1
  780. #ifdef LITTLE_ENDIAN
  781. d317 1
  782. a317 1
  783. #ifdef LITTLE_ENDIAN
  784. d350 1
  785. a350 1
  786. #ifdef LITTLE_ENDIAN
  787. @
  788.  
  789.  
  790. 1.1
  791. log
  792. @Initial revision
  793. @
  794. text
  795. @d7 8
  796. a14 2
  797.  * Copyright 1987 Regents of the University of California
  798.  * All rights reserved.
  799. d16 1
  800. a16 2
  801.  *
  802.  * $Header: netInet.h,v 2.1 88/04/03 23:02:06 andrew Exp $ SPRITE (Berkeley)
  803. @
  804.